<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Test extends CI_Controller {

    public $scraper;
    public $static_mode = FALSE; // use downloaded html page instead of online page or not

	function __construct()
	{
		parent::__construct();
		$this->load->library('domparser');
        $this->load->library('Deal');
        $this->load->library('Scraper');
        
        $this->scraper = new Scraper();
	}

	function index()
	{
		$this->load->view('test_nav_view');
	}

    function phagia()
    {
        $url = $this->static_mode ? 'static/phagia.html'
                : 'http://phagia.com.vn/tp-ho-chi-minh/pha-gia-giam-gia-sieu-khuyen-mai-hom-nay';

        $data['target'] = 'phagia';
        $data['deals'] = $this->scraper->extract($url, Scraper::TARGET_PHAGIA);

		$this->load->view('test_view', $data);
    }

    function muachung()
    {
        $url = $this->static_mode ? 'static/muachung.html'
                : 'http://muachung.vn/tp-ho-chi-minh';

        $data['target'] = 'muachung';
        $data['deals'] = $this->scraper->extract($url, Scraper::TARGET_MUACHUNG);

        // echo $data['deals'];
		$this->load->view('test_view', $data);
    }

    function nhommua()
    {
        $url = $this->static_mode ? 'static/nhommua.html'
                : 'http://www.nhommua.com/tp-ho-chi-minh/';

        $data['target'] = 'nhommua';
        $data['deals'] = $this->scraper->extract($url, Scraper::TARGET_NHOMMUA);

		$this->load->view('test_view', $data);
    }
}

/* End of file test.php */
/* Location: ./application/controllers/test.php */